<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新增活动</title>
<link href="${rc.getContextPath()}/resources/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/common.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.validate.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/messages_cn.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/input.js"></script>
<script type="text/javascript" src="${base}/js/My97DatePicker4_8/WdatePicker.js"></script>
<script type="text/javascript" src="${base}/js/ajaxupload.js"></script>
 <!-- 引入弹出JS begin -->
<script type="text/javascript" src="${rc.getContextPath()}/js/lhgdialog/lhgdialog.min.js?self=true"></script>
<!-- 引入弹出JS end -->
 
<script>
var base = '${rc.getContextPath()}';
$().ready(function() {

	var $inputForm = $("#inputForm");
	
	// 表单验证
	$inputForm.validate({
		errorClass: "fieldError",
		rules: {
			title: {
				required:true
			}
 
			
		}
	});
	
	
	
	initUploadButton("titleImage");
	initUploadButton("conentImage");
	
	
});


function trim(str){ 
	  return str.replace(/^\s+|\s+$/g,''); 
} 
function save(){
	editor.sync();
	 
	$('#inputForm').submit();
}
function back(){
	$.dialog.tips("返回中,请稍等...",600,"loading.gif");
	window.location.href='list.html ';
}


function initUploadButton(buttonId){
	var button = $("#"+buttonId);
	var exts = "jpg|png|gif",paths = "|";
	new AjaxUpload(button,
	{   
			action: '${base}/content/admin/uploadImage.html',   
			name: 'uploadFile',
		onSubmit : function(file, ext)
		{     
       		if ( !RegExp( "\.(?:" + exts + ")$$", "i" ).test(file) ) 
       		{
       			$.dialog.alert("只能上传以下类型：" + exts).zindex();
				return false;
			}          		         
		 	},   
		 	onComplete: function(file, response,statusText)
		 	{   
			var response = jQuery.parseJSON(response);
		 		//eval("var response = " + response + ";");
		 		if(response.status=="error")
			{
		 			$.dialog.alert("上传失败！") ;
			}
			else 
			{
				$("#"+buttonId+"Path").val(response.path);
				$.dialog.alert("上传成功！") ;
			}
		}   
	}); 
}
//预览图片
function imgShow(name) {
	if($("#"+name).val()=="") {
		$.dialog.alert("请先选择上传图片");
		return;
	}
	var path = $("#"+name).val();
	var url = '<img src="'+path+'"  />';
	$.dialog({
		lock: true,
		width:'700px',
		height:'315px',
		content: url,
		cancelVal: '关闭',
		autoSize:true,
	    cancel: function(){ //请求成功后处理函数。
	    	
		}
	});

}

function clearImage(id){
	
	$("#"+id).val("");
}


</script>

<script type="text/javascript" charset="utf-8">
    window.UEDITOR_HOME_URL = "${rc.getContextPath()}/ueditor/";  //UEDITOR_HOME_URL、config、all这三个顺序不能改变
</script>
<script type="text/javascript" src="${rc.getContextPath()}/ueditor/editor_config.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/ueditor/editor_all_min.js"></script>

</head>

<body>


<div class="path">
		  <a href="#"> 新增活动</a>
	</div>
	
	<form id="inputForm" action="${base!}/event/admin/saveEvent.html" method="post">
 
 
		<!-- 基本功能begin -->
		<table class="input tabContent">
			<colgroup>
				<col  width="15%"/>
				<col  width="35%"/>
				<col  width="15%"/>
				<col  width="35%"/>
			</colgroup>
			<tr>
				<th>
					<span class="requiredField">*</span>活动名称:
				</th>
				<td   >
					 	<input  type="text"  value="" name= "title" id="title"/>
				</td>
				 	 <th>
					 外联URL(请以http://开头):
				</th>
				<td  >
						<input  type="text"  value="" name= "url" id="url" />
				</td>
			</tr>
 

			<tr>
				<th>
					 活动详细时间:
				</th>
				<td >
						<input  type="text"  value="" name= "eventTime"  id= "eventTime" />
				</td>
				 <th>
					 活动地点:
				</th>
				<td >
						<input  type="text"  value="" name= "eventVenue"  id= "eventVenue"/>
				</td>
			</tr>
 			<tr>
				<th>
					 活动费用说明:
				</th>
				<td colspan="3">
						<input  type="text"  value="" name= "cost"  id="cost"/>
				</td>
 
			</tr>
 
			<tr>
				  <th>
					 活动简介:
				</th>
				<td   >
 
						<textarea  name="eventDesc" id = "eventDesc" cols="40"    style="FONT-SIZE: 12px;"></textarea>
				</td>
				<th>
					活动额外信息:
				</th>
				<td  >
						<textarea  name="moreInfo" id = "moreInfo"  cols="40"   style="FONT-SIZE: 12px;" ></textarea>
				</td>
 
			</tr>
			
			<tr>
			    <th>
					 活动标题图:
				</th>
				<td  class="border_b"   valign="top"  >
					<input type ="text" id="titleImagePath" name="titleImg"   readonly="readonly"  /><br />
					
					<input id="titleImage"  class="button"  type="button" value="上传" />
					<input id="cleartitleImage"  class="button" onclick="clearImage('titleImagePath')" type="button" value="清除" />
					<input type="button"  class="button" value="预览" onclick="imgShow('titleImagePath')"/>
					 
					<br />上传类型：*.png;*.bmp;*.jpeg;*.jpg
				</td>	
 			    <th>
					 活动内容图:
				</th>
				<td  valign="top"  >
					<input type ="text" id="conentImagePath" name="conentImg"   readonly="readonly"  /><br />
					
					<input id="conentImage"  class="button"  type="button" value="上传" />
					<input id="clearconentImage"  class="button" onclick="clearImage('conentImagePath')" type="button" value="清除" />
					<input type="button"  class="button" value="预览" onclick="imgShow('conentImagePath')"/>
					 
					<br />上传类型：*.png;*.bmp;*.jpeg;*.jpg
				</td>
			</tr>
			 <tr>
			    <th>
					 活动状态:
				</th>
				<td  > 
						<select  name="eventStatus"  >
								<option value="1"  >发布</option>
								<option value="2" >屏蔽</option>
						</select>
				</td>
 			    <th>
					 是否置顶:
				</th>
				<td  >
						<select  name="isUp"  >
								<option value="1"  >否</option>
								<option value="2" >是</option>
						</select>
				</td>
			</tr>
			 <tr>
			    <th>
					 是否头条:
				</th>
				<td  >
						<select  name="isTop"  >
								<option value="1"  >否</option>
								<option value="2" >是</option>
						</select>
				</td>
 			    <th>
					 
				</th>
				<td  >
					 <input type="hidden" name="isCases" value="1"/>
				</td>
			</tr>
			
			 <tr>
				<th>
					 活动内容:
				</th>
				<td colspan="3">
						<textarea  name="content" id = "ueditTxt"  ><p></p></textarea>
						<script type="text/javascript">
								var editor = new UE.ui.Editor({ initialFrameWidth:640 , minFrameHeight:170  });
			   					        editor.render("ueditTxt");
			
						</script>
			
				</td>
 
			</tr>
</table>
<table class="input">
			<colgroup>
				<col  width="15%"/>
				<col  width="35%"/>
				<col  width="15%"/>
				<col  width="35%"/>
			</colgroup>
			<tr>
				<td>

				</td>
				<td colspan="3">
					<input type="button" class="button" value="保存"  onclick="save()"/>
					<input type="button" id="backButton" class="button" value="返回" onclick="javascript:back()" />
				</td>
			</tr>
		</table> 
</form>

</body>
</html>